Escape sequences

From Cppreference

Jump to: navigation, search

Escape sequences are used to define certain special characters within string literals.

The following escape sequences are available:

Escape
sequence
Description
\' single quote (byte 0x27)
\" double quote (byte 0x22)
\\ backslash (byte 0x5c)
\0 null character (byte 0x00)
\a audible bell (byte 0x07)
\b backspace (byte 0x08)
\f form feed - new page (byte 0x0c)
\n line feed - new line (byte 0x0a)
\r carriage return (byte 0x0d)
\t horizontal tab (byte 0x09)
\v vertical tab (byte 0x0b)
\nnn octal byte (nnn)
\nn hexadecimal byte (nn)

[edit] Example

#include <iostream>
 
int main()
{
    std::printf("This\nis\na\ntest\n\nShe said, \"How are you?\"\n");}

Output:

This
is
a
test
 
She said, "How are you?"

[edit] See also

ASCII chart

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox
In other languages